<#assign menuId=4>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>大货通知单-${Application.systemName!}</title>
        <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
        <!-- bootstrap 3.0.2 -->
        <link href="../css/bootstrap.min.css" rel="stylesheet" type="text/css" />
        <!-- font Awesome -->
        <link href="../css/font-awesome.min.css" rel="stylesheet" type="text/css" />
        <!-- Ionicons -->
        <link href="../css/ionicons.min.css" rel="stylesheet" type="text/css" />
        <!-- Theme style -->
        <link href="../css/AdminLTE.css" rel="stylesheet" type="text/css" />
        <!--datetimepicker-->
		<!--<link rel="stylesheet" type="text/css" href="../css/datetimepicker/bootstrap-combined.min.css"/>-->
		<link rel="stylesheet" type="text/css" href="../css/datetimepicker/bootstrap-datetimepicker.min.css"/>
        <!-- bootstrap wysihtml5 - text editor -->
        <link href="../css/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css" rel="stylesheet" type="text/css" />
        <link href="../css/myself.css" rel="stylesheet" type="text/css" />
        <style type="text/css">
            *{
                margin: 0;
                padding: 0;
            }
            .content{
            	padding-left: 0;
            }
            .pull-left{
				border-left: 6px solid #3882FF;
				padding: 0 0 0 10px;
				font-size: 14px;
				font-weight: bold;
				margin: 15px 0 10px 0;
			}
			.nother{
				border: 1px solid #ccc; 
				padding: 6px 30px;
			}
			.style label{
				width: 15%;
			}
			.style label:nth-last-child{
				width: 5%;
			}
	        .table-bordered{
	        	border-collapse: collapse;
	        }
	        
	        a{
	        	cursor: pointer;
	        }
	        .row{
		        	padding: 0 0 0 20px;
		    }
		    .gray, .red{
		    	font-size: 16px;
		    }
		    /*新增样式*/
    		.ol_left{
	            width: 100%;
	            height: 30px;
	            line-height: 30px;
	            padding: 0;
	        }
	        .ol_left>li{
	            float: left;
	            margin-right: 5px;
	        }
	        .ol_left li, .ol_left{
	        	margin-bottom: 0;
	        }
	        
	        .inpt tr td input{
	        	width: 100%;
	        	height: 100%;
	        	border: 0;
	        	font-size: 12px;
	        	text-align: center;
	        }
	        .table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td {
			    vertical-align: middle;
			}
			
			
			 /* 下载和上传按钮样式 */
	        
			.file {
			    position: relative;
			    display: inline-block;
			    background: #D0EEFF;
			    border: 1px solid #99D3F5;
			    border-radius: 4px;
			    padding: 4px 12px;
			    overflow: hidden;
			    color: #1E88C7;
			    text-decoration: none;
			    text-indent: 0;
			    line-height: 20px;
			}
			.file input {
			    position: absolute;
			    font-size: 100px;
			    right: 0;
			    top: 0;
			    opacity: 0;
			}
			.file:hover {
			    background: #AADFFD;
			    border-color: #78C3F3;
			    color: #004974;
			    text-decoration: none;
			}
			#fileName, #fileName1{
	        	color: #3882ff;
	        }
	       
	        #tijiao{
			    display: inline-block;
			    background: #D0EEFF;
			    border: 1px solid #99D3F5;
			    border-radius: 4px;
			    padding: 4px 12px;
			    overflow: hidden;
			    color: #1E88C7;
			    text-decoration: none;
			    text-indent: 0;
			    line-height: 20px;
	        }
        </style>
    </head>
    <body class="skin-blue">
        <!-- header logo: style can be found in header.less -->
		<#include "../header.html"/>
		
        <div class="wrapper row-offcanvas row-offcanvas-left">
            <#include "../menu.html"/>

            <!-- Right side column. Contains the navbar and content of the page -->
           <aside class="right-side">
                <!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1>填写大货生产通知单</h1>
                    <ol class="ol_left">
		                <li>当前位置：</li>
		                <li><a href="#">大货订单</a></li>
		                <li>> 填写大货生产通知单</li>
		            </ol>
		            <hr class="no-margin" />
            	</section>
                <!-- Main content -->
                
                <section class="content">

                    <div class='row'>
                        <div class='col-md-12'>
                        <#list productionDetailResults as production>
                        	
                            <div class='box' style="padding: 20px;">
                            	<span class="id" style="display:none;">${production.id!}</span>
                                <div class="marginBottom center">
				               		<div class="pull-left">填写工厂交期</div>
				               		<div class="pull-right">
				               			<span style="margin-right: 20px; font-size: 16px;">共${production_index+1}/${productionDetailResults?size}件</span>
				               			<span class="gray">客户交期：</span>
				               			<#if production.remainingTime?? && production.remainingTime gt 0>
						                       <b class="red">剩余${production.remainingTime!}天</b>
						                       <#elseif production.remainingTime?? && production.remainingTime lt 0>
						                       <b class="red">超期${production.remainingTime?abs}天</b>
						                       <#elseif production.remainingTime??>
						                       <b class="red">剩余${production.remainingTime!}天</b>
						                </#if>
				               		</div>
				               	</div>
				               	
			               		<table class="table no-border" style="margin-bottom: 20px;">
				               		<tr style="margin-bottom: 10px"> 
				               			<td width="8%" style="text-align: right; font-weight: normal">选择工厂：</td>
				               			<td width="22%">
				               				<select id="factoryId" class="form-control select2" style="line-height: 29px"> 
								                  <option selected="selected" value="0">请选择</option> 
								                  <#list factorires as factory>
								                  <#if production.factoryId??&& production.factoryId==factory.id>
								                  	<option value="${factory.id}" selected="selected">${factory.name!}</option>
								                  <#else>
								                  	<option value="${factory.id}">${factory.name!}</option>
								                  </#if>
								                  </#list>
							                </select>
				               			</td>
				               			<td width="8%" style="text-align: right;font-weight: normal">工厂交期：</td>
				               			<td width="62%">
				               				<div class="input-group date form_datetime" style="width: 40%"> 
												<input id="productionEndDate" class="form-control" size="60" type="text" value="<#if production.deliveryDate??>${production.deliveryDate?string('yyyy-MM-dd HH:mm')}</#if>"> 
												<span class="input-group-addon">
													<span class="glyphicon glyphicon-th"></span>
												</span>
											</div>
				               			</td>
				               		</tr>
				               		<tr>
				               			<td width="8%" style="text-align: right;font-weight: normal">选择合同：</td>
				               			<td colspan="3" width="92%">
				               				<form id="form" class="file_fa" action="" method="post">
				               					<#if production.fileName??>
                                 					<div class="fileName" style="margin-bottom: 5px">${production.fileName!}</div>
                                 					<a href="javascript:;" class="file">
												    	<input type="file"  multiple  onchange="javascript:showFileName($(this));">重新选择合同
													</a>
													<span id="fileName"></span>
												<#else>
													<a href="javascript:;" class="file">
												    	<input type="file"  multiple  onchange="javascript:showFileName($(this));">选择合同
													</a>
													<span id="fileName"></span>
												</#if>
                              				</form>
				               			</td>
				               		</tr>
				               	</table>
			               		
						       	<div class="clearfix center">
						       		<div class="pull-left center marginBottom">填写款式信息</div>
						       	</div>
						           	<table class="table text-center center table-bordered order-list">
					                   	<tr>
					                       	<td colspan="5" class="left-text">
					                           	<span style="margin-right: 50px;">子订单号：${production.code!}</span>
					                           	<span>设计款号:${production.patternNo!}</span>
					                           	<span style="margin-left: 20px;">
                                            		是否有样衣
                                            		<#if (production.isExists!)=="是">
		                                            <input class="isExists" type="checkbox" checked="checked" />
		                                            <#else>
		                                            <input class="isExists" type="checkbox" />
		                                            </#if>
		                                        </span>
					                       	</td>
					                   	</tr>
					                   	<tr>
					                   		<td width="50%">
	                                            <div class="Design_draft"><img src="${Application.accessFileUrl}${production.mainImage!}" alt="" /></div>
	                                        </td>
	                                        <td>
					                       		<table class="table table-bordered inpt">
					                       			<tr>
					                       				<td colspan="8">
					                       					<table class="table table-bordered">
					                       						<tr>
					                       							<td>设计款式说明</td>
					                       							<td>
					                       								<div class="form-group textarea">
								                                            <textarea id="description" class="form-control" rows="3" placeholder="输入设计款式说明">${production.description!}</textarea>
								                                        </div>
					                       							</td>
					                       						</tr>
					                       					</table>
					                       				</td>
					                       			</tr>
					                       			<tr>
					                       				<th width="14%">颜色</th>
					                       				<th width="12%">XS</th>
					                       				<th width="12%">S</th>
					                       				<th width="12%">M</th>
					                       				<th width="12%">L</th>
					                       				<th width="12%">XL</th>
					                       				<th width="12%">总计</th>
					                       				<th width="14%">产前样</th>
					                       			</tr>
					                       			<#list production.productionBeforePatternSizes as beforePatternSize>
					                       			<tr> 
					                       				<td style="padding: 0;"><input type="text" value="${beforePatternSize.color!}" /></td>
					                       				<td style="padding: 0;"><input class="num" name="size" type="text" value="${beforePatternSize.xsAmount!}" /></td>
					                       				<td style="padding: 0;"><input class="num" name="size" type="text" value="${beforePatternSize.sAmount!}"/></td>
					                       				<td style="padding: 0;"><input class="num" name="size" type="text" value="${beforePatternSize.mAmount!}"/></td>
					                       				<td style="padding: 0;"><input class="num" name="size" type="text" value="${beforePatternSize.lAmount!}"/></td>
					                       				<td style="padding: 0;"><input class="num" name="size" type="text" value="${beforePatternSize.xlAmount!}"/></td>
					                       				<td name="total"></td>
					                       				<td>
					                       					<div class="red_circle delete" style="cursor: pointer;">
	                                   							<div>
	                                   								
	                                   							</div>
	                                   						</div>
					                       				</td>
					                       			</tr>
					                       			</#list>
					                       			<tr class="no_add">
	                                   					<td colspan="8">
	                                   						<div class="add" style="cursor: pointer;">+添加一行</div>
	                                   					</td>
	                                       			</tr>
					                       			<tr>
					                       				<td colspan="8"  class="right-text">
		                                                    <span class="pull-right">共<span id="count">0</span>件</span>
		                                                </td>	
					                       			</tr>
					                       			
					                       		</table>
					                       	</td>
					                   	</tr>
				                        <tr>
				                        	<td colspan="2">
				                        		<table class="table table-bordered inpt">
				                                    <tr>
				                                        <th width="8%">颜色</th>
				                                        <th width="8%">XS</th>
				                                        <th width="8%">S</th>
				                                        <th width="8%">M</th>
				                                        <th width="8%">L</th>
				                                        <th width="8%">XL</th>
				                                        <th width="8%">总计(件)</th>
				                                        <th width="8%">单价(元)</th>
				                                        <th width="8%">总价(元)</th>
				                                        <th width="22%">到货地点</th>
				                                        <th width="6%"></th>
				                                    </tr>
				                                    <#list production.productionPatternSizes as pps>
				                                    <tr>
				                                    	<td style="padding: 0;"><input class="color" type="text" value="${pps.color!}" /></td>
					                       				<td style="padding: 0;"><input class="num" name="size1" type="text" value="${pps.xsAmount!}"/></td>
					                       				<td style="padding: 0;"><input class="num" name="size1" type="text" value="${pps.sAmount!}"/></td>
					                       				<td style="padding: 0;"><input class="num" name="size1" type="text" value="${pps.mAmount!}"/></td>
					                       				<td style="padding: 0;"><input class="num" name="size1" type="text" value="${pps.lAmount!}"/></td>
					                       				<td style="padding: 0;"><input class="num" name="size1" type="text" value="${pps.xlAmount!}"/></td>
					                       				<td style="padding: 0;" name="total1"></td>
					                       				<td style="padding: 0;"><input class="num" name="price" type="text" value="${pps.price!}"/></td>
					                       				<td style="padding: 0;" name="allprice"></td>
					                       				<td style="padding: 0;"><input class="address"  type="text" value="${pps.arriveAddress!}"/></td>
				                                        <td>
					                       					<div class="red_circle delete" style="cursor: pointer;">
	                                   							<div></div>
	                                   						</div>
					                       				</td>
				                                    </tr>
				                                    </#list>
				                                    <tr class="no_add1">
	                                   					<td colspan="11">
	                                   						<div class="add1" style="cursor: pointer;">+添加一行</div>
	                                   					</td>
	                                       			</tr>
					                       			<tr>
					                       				<td colspan="11"  class="right-text">
		                                                    <span class="pull-right">共<span id="count1">0</span>件</span>
		                                                </td>	
					                       			</tr>
				                                </table>
				                        	</td>
				                        </tr>
				                       	
						           	</table>
	                                <div class=" custorm-view center clearfix">
                                       	<span class="pull-left">款式细节明细</span>
	                               	</div>
	                                <div class='center marign-top'>
                                        <textarea id="detailDescription"  name="editor${production_index*2+1}" rows="10" cols="80">
											${production.detailDescription!}
                                        </textarea>
	                                </div>
	                                <div class=" custorm-view center clearfix">
	                                    <span class="pull-left">面辅料明细</span>
	                               	</div>
	                                <div class='center marign-top'>
	                                        <textarea id="accessoryDetail"  name="editor${production_index*2+2}" rows="10" cols="80">
												${production.accessoryDetail!}
	                                        </textarea>
	                                </div>
	                                <div class="clearfix center">
	                                	<div class="pull-left center">折叠包装方法</div>
	                                </div>
                            <table class="table center table-bordered">
                                <tr>
                                    <td width="15%">折叠方法</td>
                                    <td>
                                        <div class="style">
											<input type="radio" name="fold${production_index}" id="nub1_1" value="轻烫" /> <label
												for="nub1_1">轻烫</label> <input type="radio" name="fold${production_index}"
												id="nub1_2" value="骨位烫" /> <label for="nub1_2">骨位烫</label>
											<input type="radio" name="fold${production_index}" id="nub1_3" value="正常烫" /> <label
												for="nub1_3">正常烫</label> <input type="radio" name="fold${production_index}"
												id="nub1_4" value="其他" /> <label for="nub1_4">其他</label> <input
												class="nother" id="fold${production_index}" placeholder="Enter ..." type="text">
										</div>
									</td>
                                </tr>
                                <tr>
                                    <td width="15%">包装方法</td>
                                    <td>
                                        <div class="style">
												<input type="radio" name="package${production_index}" id="nub2_1" value="雇装" /> <label
													for="nub2_1">雇装</label> <input type="radio" name="package${production_index}"
													id="nub2_2" value="挂装" /> <label for="nub2_2">挂装</label> <input
													type="radio" name="package${production_index}" id="nub2_3" value="企装" /> <label
													for="nub2_3">企装</label> <input type="radio" name="package${production_index}"
													id="nub2_4" value="其他" /> <label for="nub2_4">其他</label> <input
													class="nother" id="package" placeholder="Enter ..."
													type="text">
										</div>
									</td>
                                </tr>
                            </table>
                            <div class="clearfix center">
                            	<div class="pull-left center">验货</div>
                            </div>
                            
                            <table class="table center table-bordered">
                                <tr>
                                    <td width="15%">验货标准</td>
	                                		<td>
	                                			<div class="style">
                                    					<input type="radio" name="check${production_index}" id="nub3_1" value="AQL1.5" />
	                                    				<label for="nub3_1">AQL1.5</label>
	                                    				<input type="radio" name="check${production_index}" id="nub3_2" value="AQL2.5" />
	                                    				<label for="nub3_2">AQL2.5</label>
	                                    				<input type="radio" name="check${production_index}" id="nub3_3" value="AQL4.0" />
	                                    				<label for="nub3_3">AQL4.0</label>
	                                    				<input type="radio" name="check${production_index}" id="nub3_4" value="其他" />
			                                    		<label for="nub3_4">其他</label>

				                                        <input class="nother" id="check" placeholder="Enter ..." type="text">
	                                			</div>
	                                		</td>
                                </tr>
                                <tr>
                                    <td width="15%">测试要求</td>
                                    <td>
                                        <div class="form-group" style="margin-bottom: 0;">
                                            <input id="testRequest" value="${production.testRequest!}" class="form-control" placeholder="Enter ..." type="text">
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td width="15%">中查</td>
                                    <td>
                                        <div class="form-group" style="margin-bottom: 0;width: 30%;">
                                            <input id="middleCheck" value="${production.middleCheck!}" class="form-control" placeholder="Enter ..." type="text">
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td width="15%">尾查</td>
                                    <td>
                                        <div class="form-group" style="margin-bottom: 0;width: 30%;">
                                            <input id="lastCheck" value="${production.lastCheck!}" class="form-control" placeholder="Enter ..." type="text">
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td width="15%">第三方验货</td>
                                    <td>
                                        <div class="form-group" style="margin-bottom: 0;">
                                            <input id="thirdparty" value="${production.thirdparty!}" class="form-control" placeholder="Enter ..." type="text" style="width: 30%;">
                                        </div>
                                    </td>
                                </tr>
                            </table>
							<div class="clearfix center">
								<div class="pull-left center">备注</div>
							</div>
                            
                            <div class="form-group center">
                                <textarea id="memo" class="form-control" rows="3" placeholder="Enter ...">${production.memo!}</textarea>
                            </div>
                            <div class="center">
                                <div class="pull-left" style="border: none; padding: 0;">
                                    <a href="detail?id=${production.productionId!}" class="btn btn-default">取消</a>
                                </div>
                                <div class="pull-right" style="margin: 15px 0 10px 0">
                                    <#if production_index!=0>
		                                	<a href="#" class="btn btn-default" id="last" style="margin-right: 5px;">上一款</a>
		                            </#if>
		                            <#if productionDetailResults?size!=1>
		                                <a href="#" class="btn btn-primary next" id="next">共${production_index+1}/${productionDetailResults?size}款，
			                                <#if production_index+1==productionDetailResults?size>
			                                	生成预览
			                                <#else>
			                                	填写下一款
			                               	</#if>
		                                </a>
		                            <#else>
		                            	<#if index??>
		                                	<a href="#" class="btn btn-primary next" id="next">确定修改</a>
		                                	<#else>
		                                	<a href="#" class="btn btn-primary next" id="next">确定</a>
		                               	</#if>
		                            </#if>
                                </div>
                                <div class="clear" style="clear: both;"></div>
                            </div>
                           </div><!-- box -->
                           </#list>
                        </div><!-- /.col-->
                    </div><!-- ./row -->
                </section><!-- /.content -->
            </aside><!-- /.right-side -->
        </div><!-- ./wrapper -->
        <!-- jQuery 2.0.2 -->
        <style type="text/css"></style>
        
        <!-- jQuery 2.0.2 -->
        <script src="../js/jquery.min.js"></script>
        <!-- Bootstrap -->
        <script src="../js/bootstrap.min.js" type="text/javascript"></script>
        <!-- AdminLTE App -->
        <script src="../js/AdminLTE/app.js" type="text/javascript"></script>
        <!-- AdminLTE for demo purposes -->
        
        <!-- CK Editor -->
        <script src="../js/plugins/ckeditor/ckeditor.js" type="text/javascript"></script>
        <!-- Bootstrap WYSIHTML5 -->
        <script src="../js/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js" type="text/javascript"></script>
        <!--datepickes-->
		<script src="../js/plugins/datetimerpicker/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
	
		<script src="../js/plugins/datetimerpicker/locales/bootstrap-datetimepicker.zh-CN.js" type="text/javascript"></script>
       	
      
      	<script type="text/javascript" src="../js/bootstrap-select.js"></script>
      <script type="text/javascript">
      		model= [];
            $(function() {
            	CKEDITOR.config.height = 500;
                // Replace the <textarea id="editor1"> with a CKEditor
                // instance, using default configuration.
                <#list productionDetailResults as production>
                	model[${production_index*2+1}] = CKEDITOR.replace('editor${production_index*2+1}');
                	model[${production_index*2+2}] = CKEDITOR.replace('editor${production_index*2+2}');
                </#list>
                //bootstrap WYSIHTML5 - text editor
                $(".textarea").wysihtml5();
            	$('input[name="size"]').change(calculate2);
            	$('input[name="size1"]').change(calculate1);
            	$('input[name="price"]').change(calculate1);
            	calculate1();
            	calculate2();
            	isNum();
            });
            
            //尺码数量与价格是否合法监听事件
            function isNum(){
            	var num = $('.num');
            	for(var i=0;i<num.length;i++){
            		num.eq(i).blur(function(){
            			if(isNaN($(this).val())){
            				alert("输入的不是纯数字");
            				$(this).val("");
            				calculate1();
                        	calculate2();
            			}
            		})
            	}
            }
            function calculate1(){
            	var total1s = $('td[name="total1"]');
            	for(var i=0;i<total1s.length;i++){
            		var inputs = total1s.eq(i).parent().find('input[name="size1"]');
            		var price = total1s.eq(i).parent().find('input[name="price"]');
            		var allprice = total1s.eq(i).parent().find('td[name="allprice"]');
            		var total=0;
            		for(var j=0;j<inputs.length;j++){
            			var num=inputs.eq(j).val();
                		if(num&&!isNaN(num)){
                			total+=parseInt(num);
                		}
            		}
            		total1s.eq(i).html(total);
            		if(!isNaN(price.val())&&!isNaN(total1s.eq(i).html())){
            			allprice.html(price.val()*total1s.eq(i).html());
            		}
            	}
            	var counts = $('span[id="count1"]');
            	for(var i=0;i<counts.length;i++){
            		var tds = counts.eq(i).parent().parent().parent().parent().find('td[name="total1"]');
            		var total=0;
            		for(var j=0;j<tds.length;j++){
            			var num=tds.eq(j).html();
                		if(num&&!isNaN(num)){
                			total+=parseInt(num);
                		}
            		}
            		counts.eq(i).html(total);
            	}
            }
            function calculate2(){
            	var totals = $('td[name="total"]');
            	for(var i=0;i<totals.length;i++){
            		var inputs = totals.eq(i).parent().find('input[name="size"]');
            		var total=0;
            		for(var j=0;j<inputs.length;j++){
            			var num=inputs.eq(j).val();
                		if(num&&!isNaN(num)){
                			total+=parseInt(num);
                		}
            		}
            		totals.eq(i).html(total);
            	}
            	var counts = $('span[id="count"]');
            	for(var i=0;i<counts.length;i++){
            		var tds = counts.eq(i).parent().parent().parent().parent().find('td[name="total"]');
            		var total=0;
            		for(var j=0;j<tds.length;j++){
            			var num=tds.eq(j).html();
                		if(num&&!isNaN(num)){
                			total+=parseInt(num);
                		}
            		}
            		counts.eq(i).html(total);
            	}
            }
            $(function(){
            	$('.box:not(:first)').hide();
            	for(var i=0;i<$('.box').length;i++){
            		$('.box').eq(i).find('#last').click(showLast);
            		if(i!=$('.box').length-1)
            		$('.box').eq(i).find('#next').click(showNext);
            	}
            })
            function showLast(){
            	var index=$('.box').index($(this).parents('.box'));
            	$(this).parents('.box').hide();
            	$('.box').eq(index-1).show();
            }
            function showNext(){
            	var index=$('.box').index($(this).parents('.box'));
            	//非空验证
            	if(!notNull(index)) return false;
            	$(this).parents('.box').hide();
            	$('.box').eq(index+1).show();
            }
            
            //非空验证
            function notNull(index){
				//工厂
            	var factoryId = $('.box').eq(index).find('#factoryId').val();
				if(factoryId=='0'){
					alert("工厂不能为空");
					return false;
				}
				//工厂交期
				var productionEndDate = $('.box').eq(index).find('#productionEndDate').val();
				if(productionEndDate==null||productionEndDate==''){
					alert("工厂交期不能为空");
					return false;
				}
				//大货合同
				var file = $('.box').eq(index).find('[type="file"]').val();
				//反选的文件名
				var fileName = $('.box').eq(index).find('.fileName').html()
				if(fileName==null&&(file==null||file=='')){
					alert("合同不能为空");
					return false;
				}
				//颜色
				var color = $('.box').eq(index).find('.color');
				for(var i=0;i<color.length;i++){
					var num = i+1;
					var colorVal = color.eq(i).val();
					if(colorVal==null||colorVal==''){
						alert("第"+num+"行颜色不能为空");
						return false;
					}
				}
				var total = $('.box').eq(index).find('[name="total1"]');
				for(var i=0;i<total.length;i++){
					var num = i+1;
					var totalVal = total.eq(i).html();
					if(totalVal==null||totalVal==''){
						alert("第"+num+"行大货数量不能为空");
						return false;
					}
				}
				var price = $('.box').eq(index).find('[name="price"]');
				for(var i=0;i<price.length;i++){
					var num = i+1;
					var priceVal = price.eq(i).val();
					if(priceVal==null||priceVal==''){
						alert("第"+num+"行单价不能为空");
						return false;
					}
				}
				var address = $('.box').eq(index).find('.address');
				for(var i=0;i<address.length;i++){
					var num = i+1;
					var addressVal = address.eq(i).val();
					if(addressVal==null||addressVal==''){
						alert("第"+num+"行到货地址不能为空");
						return false;
					}
				}
				var foldMethod = $('.box').eq(index).find('[name="fold'+index+'"]').val();
				if(foldMethod==null||foldMethod==''){
					alert("折叠方法不能为空");
					return false;
				}
				var packageMethod = $('.box').eq(index).find('[name="package'+index+'"]').val();
				if(packageMethod==null||packageMethod==''){
					alert("包装方法不能为空");
					return false;
				}
				var checkStandard = $('.box').eq(index).find('[name="check'+index+'"]').val();
				if(checkStandard==null||checkStandard==''){
					alert("验货标准不能为空");
					return false;
				}
				var testRequest = $('.box').eq(index).find('#testRequest').val();
				if(testRequest==null||testRequest==''){
					alert("测试要求不能为空");
					return false;
				}
				var middleCheck = $('.box').eq(index).find('#middleCheck').val();
				if(middleCheck==null||middleCheck==''){
					alert("中查人员不能为空");
					return false;
				}
				var lastCheck = $('.box').eq(index).find('#lastCheck').val();
				if(lastCheck==null||lastCheck==''){
					alert("尾查人员不能为空");
					return false;
				}
				var thirdparty = $('.box').eq(index).find('#thirdparty').val();
				if(thirdparty==null||thirdparty==''){
					alert("第三方验货不能为空");
					return false;
				}
			 	return true;
            }
            

            function deleteTr(){
            	var table=$(this).parents('table').eq(0);
                $(this).parent().parent().remove();
                calculateTotal(table);
            }
            function deleteTr1(){
            	var table=$(this).parents('table').eq(0);
                $(this).parent().parent().remove();
                calculateTotal1(table);
            }

            function calculateTotal(table){
            	var tds=table.find('td[name="total"]');
            	var total=0;
                for(var i=0;i<tds.length;i++){
                	total+=parseInt(tds.eq(i).html());
                }
                table.find('#count').html(total);
            }
            function calculateTotal1(table){
            	var tds=table.find('td[name="total1"]');
            	var total=0;
                for(var i=0;i<tds.length;i++){
                	if(!isNaN(parseInt(tds.eq(i).html()))){
                		total+=parseInt(tds.eq(i).html());
                	}
                }
                table.find('#count1').html(total);
            }
            
           
		    $('.form_datetime').datetimepicker({
		    	format: 'yyyy-mm-dd hh:00',
		    	language:  'zh-CN',  
	            weekStart: 1,  
	            todayBtn:  1,  
	            autoclose: 1,  
	            todayHighlight: 1,  
	            startView: 2,  
	            forceParse: 0,  
	            showMeridian: 0,
	            minView: 1,
	            startDate: new Date()
		    });
			// 点击添加删除
			$('.add').click(function () {
				var tr = $('<tr> '
           					+'<td style="padding: 0;"><input type="text" /></td>'
           					+'<td style="padding: 0;"><input class="num" name="size" type="text" /></td>'
           					+'<td style="padding: 0;"><input class="num" name="size" type="text" /></td>'
           					+'<td style="padding: 0;"><input class="num" name="size" type="text" /></td>'
           					+'<td style="padding: 0;"><input class="num" name="size" type="text" /></td>'
           					+'<td style="padding: 0;"><input class="num" name="size" type="text" /></td>'
           					+'<td name="total"></td>'
           					+'<td>'
           					+'<div class="red_circle delete" style="cursor: pointer;">'
           					+'<div>'
           					+'</div>'
           					+'</div>'
           					+'</td>'
           					+'</tr>');
				$(this).parent().parent().before(tr)
				tr.find(".delete").click(deleteTr);
				tr.find('input[name="size"]').change(calculate2);
				isNum();
			});
			$('.add1').click(function () {
				var tr = $('<tr>'
                    	+'<td style="padding: 0;"><input class="color" type="text" value="" /></td>'
                    	+'<td style="padding: 0;"><input class="num" name="size1" type="text" value=""/></td>'
                    	+'<td style="padding: 0;"><input class="num" name="size1" type="text" value=""/></td>'
                    	+'<td style="padding: 0;"><input class="num" name="size1" type="text" value=""/></td>'
                    	+'<td style="padding: 0;"><input class="num" name="size1" type="text" value=""/></td>'
                    	+'<td style="padding: 0;"><input class="num" name="size1" type="text" value=""/></td>'
                    	+'<td style="padding: 0;" name="total1"></td>'
                    	+'<td style="padding: 0;"><input class="num" name="price" type="text" value=""/></td>'
                    	+'<td style="padding: 0;" name="allprice"></td>'
                    	+'<td style="padding: 0;"><input class="address" name="arrivelocation"type="text" value=""/></td>'
                    	+'<td>'
                    	+'<div class="red_circle delete" style="cursor: pointer;">'
                    	+'<div></div>'
                    	+'</div>'
                    	+'</td>'
                    	+'</tr>')
				$(this).parent().parent().before(tr);
				tr.find(".delete").click(deleteTr1);
				tr.find('input[name="size1"]').change(calculate1);
				tr.find('input[name="price"]').change(calculate1);
				isNum();
			});
            $(".delete").click(function() {
                $(this).parent().parent().remove();
            });
            
            
            function fillNotice(){
            	var boxs=$('.box');
            	var data=new FormData();
            	var productions=[];
            	for(var i=0;i<boxs.length;i++){
            		var box=boxs.eq(i);
            		var production={};
            		//工厂Id
            		production.factoryId = box.find('select[id=factoryId]').val();
            		//大货款式Id
            		production.id = box.find('.id').html();
            		//工厂交期
            		production.productionEndDate=box.find('#productionEndDate').val();
            		//产前样信息
            		var inputs=box.find('.no_add').prevAll(':not(:last)').find('input');
            		
            		production.beforePatterns=[];
            		for(var j=0;j<inputs.length/6;j++){
            			var beforePattern={};
            			beforePattern.color=inputs.eq(j*6+0).val();
            			beforePattern.xs=inputs.eq(j*6+1).val();
            			beforePattern.s=inputs.eq(j*6+2).val();
            			beforePattern.m=inputs.eq(j*6+3).val();
            			beforePattern.l=inputs.eq(j*6+4).val();
            			beforePattern.xl=inputs.eq(j*6+5).val();
            			beforePattern.count=inputs.eq(j*6+5).parent().next().html();
            			production.beforePatterns[j]=beforePattern;
            		}
            		//产前样总数
            		production.beforeCount=box.find('#count').html();
            		//大货尺码数量
            		var inputs1=box.find('.no_add1').prevAll().find('input');
            		
            		production.patterns=[];
            		for(var j=0;j<inputs1.length/8;j++){
            			
            			var pattern={};
            			pattern.color=inputs1.eq(j*8+0).val();
            			pattern.xs=inputs1.eq(j*8+1).val();
            			pattern.s=inputs1.eq(j*8+2).val();
            			pattern.m=inputs1.eq(j*8+3).val();
            			pattern.l=inputs1.eq(j*8+4).val();
            			pattern.xl=inputs1.eq(j*8+5).val();
            			pattern.count=inputs1.eq(j*8+5).parent().next().html();
            			pattern.price=inputs1.eq(j*8+6).val();
            			pattern.arrivelocation=inputs1.eq(j*8+7).val();
            			production.patterns[j]=pattern;
            		}
            		if(box.find('.isExists').is(':checked')){
            			production.isExists="是";
            		}else{
            			production.isExists="否";
            		}
            		//大货尺码总数
            		production.count=box.find('#count1').html();
            		//设计款式说明
            		production.description=box.find('#description').val();
            		//款式细节明细
            		production.detailDescription=model[i*2+1].getData();
            		//面辅料明细
            		production.accessoryDetail=model[i*2+2].getData();
            		
            		//折叠方法
            		production.foldMethod=box.find(':radio[name="fold'+i+'"]:checked').val();
            		if(production.foldMethod == undefined){
            			production.foldMethod="";
            		}
            		if(production.foldMethod=='其他'){
            			production.foldMethod=box.find('#fold').val();
            		}
            		//包装方法
            		production.packageMethod=box.find(':radio[name="package'+i+'"]:checked').val();
            		if(production.packageMethod == undefined){
            			production.packageMethod="";
            		}
            		if(production.packageMethod=='其他'){
            			production.packageMethod=box.find('#package').val();
            		}
            		//验货标准
            		production.checkStandard=box.find(':radio[name="check'+i+'"]:checked').val();
            		if(production.checkStandard == undefined){
            			production.checkStandard="";
            		}
            		if(production.checkStandard=='其他'){
            			production.checkStandard=box.find('#check').val();
            		}
            		//测试要求
            		production.testRequest=box.find('#testRequest').val();
            		//中查
            		production.middleCheck=box.find('#middleCheck').val();
            		//尾查
            		production.lastCheck=box.find('#lastCheck').val();
            		//第三方验货
            		production.thirdparty=box.find('#thirdparty').val();
            		//备注
            		production.memo=box.find('#memo').val();
            		productions[i]=production;
            		if(box.find(':file')[0].files[0]){
            			data.append('file'+i,box.find(':file')[0].files[0]);
            		}
            	}
            	data.append('productions',JSON.stringify(productions));
            	
            	$.ajax({
            		url:'edit',
            		type:'post',
            		data:data,
            		dataType:'json',
            		processData: false,  // 告诉jQuery不要去处理发送的数据
            		contentType: false,   // 告诉jQuery不要去设置Content-Type请求头
            		success:function(result){
            			if(result.head.respCode=='0000000'){
            				var param='ids='+"${ids!}";
            				if("${index!}"){
            					param+='&index='+"${index!}";
            				}
            				window.location.href="showNotices?"+param;
            			}else{
            				alert(result.body);
            			}
            		}
            	});
            }
            
            //最后一个款式的按钮点击事件，向服务器请求数据
            $('.next').eq(${productionDetailResults?size-1}).click(function(){
            	var index=$('.box').index($(this).parents('.box'));
            	//非空验证
            	if(!notNull(index)) return false;
            	fillNotice();
            });
            
            $(function(){
            	<#list productionDetailResults as production>
            	var box=$('.box').eq(${production_index});
            	box.find('input[name="fold${production_index}"][value="${production.foldMethodOther!}"]').prop('checked',true);
            	if(box.find('input[name="fold${production_index}"]:checked').length==0){
            		if('${production.foldMethodOther!}'){
            			box.find('input[name="fold${production_index}"][value="其他"]').prop('checked',true).parent().addClass('checked');
            			box.find('#fold').val('${production.foldMethodOther!}');
            		}
            	}
            	box.find('input[name="fold${production_index}"][value="${production.foldMethodOther!}"]').parent().addClass('checked');
            	box.find('input[name="package${production_index}"][value="${production.packageMethodOther!}"]').prop('checked',true);
            	if(box.find('input[name="package${production_index}"]:checked').length==0){
            		if('${production.packageMethodOther!}'){
            			box.find('input[name="package${production_index}"][value="其他"]').prop('checked',true).parent().addClass('checked');
            			box.find('#package').val('${production.packageMethodOther!}');
            		}
            	}
            	box.find('input[name="package${production_index}"][value="${production.packageMethodOther!}"]').parent().addClass('checked');
            	box.find('input[name="check${production_index}"][value="${production.checkStandardOther!}"]').prop('checked',true);
            	if(box.find('input[name="check${production_index}"]:checked').length==0){
            		if('${production.checkStandardOther!}'){
            			box.find('input[name="check${production_index}"][value="其他"]').prop('checked',true).parent().addClass('checked');
            			box.find('#check').val('${production.checkStandardOther!}');
            		}
            	}
            	box.find('input[name="check${production_index}"][value="${production.checkStandardOther!}"]').parent().addClass('checked');
            	</#list>
            })
            
            //显示选择的文件的名字
            function showFileName(value){
            	value.parent().parent().find('#fileName').html(value.val());
            }
        </script>

    </body>
</html>

